package com.sushe.dao;

import java.sql.*;

public class LoginDao {
    private static final String url="jdbc:mysql://localhost:3306/sushe";
    private static final String username="root";
    private static final String password="123456";

    public boolean select(String userName,String passWord) throws ClassNotFoundException, SQLException{
        Class.forName("com.mysql.cj.jdbc.Driver");
        String sql="select id from user where username=? and password=?";
        Connection connection= DriverManager.getConnection(url, username, password);
        PreparedStatement stmt=connection.prepareStatement(sql);
        stmt.setString(1,userName);
        stmt.setString(2,passWord);
        ResultSet rs=stmt.executeQuery();
        while(rs.next()) {
            Integer Id = rs.getInt("id");
            if(Id!=null)
                return true;
        }
        return false;
    }
}
